import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';

import {
  BaseResponse,
  TimestampsWrapper,
  PageResponse,
} from '@server/basic-dto';
import { DictionaryItem } from '@server/modules/dictionary/dto';

export class CreateContactDto {
  @ApiProperty({
    description: '名',
    type: String,
  })
  firstName: string;

  @ApiProperty({
    description: '姓',
    type: String,
  })
  lastName: string;

  @ApiProperty({
    description: '电子邮件',
    type: String,
  })
  email: string;

  @ApiProperty({
    description: '联系电话',
    type: String,
  })
  phone: string;

  @ApiProperty({
    description: '公司名称',
    type: String,
  })
  companyName: string;

  @ApiProperty({
    description: '公司类型(字典id)',
    type: String,
  })
  companyType: string;

  @ApiProperty({
    description: '国家(字典id)',
    type: String,
  })
  country: string;

  @ApiProperty({
    description: '语言环境(字典id)',
    type: String,
  })
  locale: string;

  @ApiProperty({
    description: '订阅, 1代表勾选',
    enum: [0, 1],
  })
  subscribe: string;

  @ApiProperty({
    description: '留言',
    type: String,
  })
  message: string;
}

export class ContactItem extends TimestampsWrapper {
  @ApiProperty({
    description: '名',
    type: String,
  })
  firstName: string;

  @ApiProperty({
    description: '姓',
    type: String,
  })
  lastName: string;

  @ApiProperty({
    description: '电子邮件',
    type: String,
  })
  email: string;

  @ApiProperty({
    description: '联系电话',
    type: String,
  })
  phone: string;

  @ApiProperty({
    description: '公司名称',
    type: String,
  })
  companyName: string;

  @ApiProperty({
    description: '公司类型',
    type: DictionaryItem,
  })
  @Type(() => DictionaryItem)
  companyType: DictionaryItem;

  @ApiProperty({
    description: '国家',
    type: DictionaryItem,
  })
  @Type(() => DictionaryItem)
  country: DictionaryItem;

  @ApiProperty({
    description: '语言环境',
    type: DictionaryItem,
  })
  locale: string;

  @ApiProperty({
    description: '订阅, 1代表勾选',
    enum: [0, 1],
  })
  subscribe: string;

  @ApiProperty({
    description: '留言',
    type: String,
  })
  message: string;
}

export class ContactList extends PageResponse {
  @ApiProperty({
    description: '联系列表',
    isArray: true,
    type: ContactItem,
  })
  @Type(() => ContactItem)
  list: Array<ContactItem>;
}

export class ContactListResponse extends BaseResponse {
  @ApiProperty({
    description: '列表分页信息',
    type: ContactList,
  })
  @Type(() => ContactList)
  data?: ContactList;
}
